package com.forum.system.service.impl;

import com.forum.common.utils.DateUtils;
import com.forum.system.domain.TbPost;
import com.forum.system.mapper.TbPostMapper;
import com.forum.system.service.ITbPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 贴子Service业务层处理
 *
 * @author forum
 * @date 2024-11-14
 */
@Service
public class TbPostServiceImpl implements ITbPostService
{
    @Autowired
    private TbPostMapper tbPostMapper;

    /**
     * 查询贴子
     *
     * @param id 贴子主键
     * @return 贴子
     */
    @Override
    public TbPost selectTbPostById(Long id)
    {
        return tbPostMapper.selectTbPostById(id);
    }

    /**
     * 查询贴子列表
     *
     * @param tbPost 贴子
     * @return 贴子
     */
    @Override
    public List<TbPost> selectTbPostList(TbPost tbPost)
    {
        return tbPostMapper.selectTbPostList(tbPost);
    }

    /**
     * 新增贴子
     *
     * @param tbPost 贴子
     * @return 结果
     */
    @Override
    public int insertTbPost(TbPost tbPost)
    {
        tbPost.setCreateTime(DateUtils.getNowDate());
        tbPost.setStatus("0");
        return tbPostMapper.insertTbPost(tbPost);
    }

    /**
     * 修改贴子
     *
     * @param tbPost 贴子
     * @return 结果
     */
    @Override
    public int updateTbPost(TbPost tbPost)
    {
        return tbPostMapper.updateTbPost(tbPost);
    }

    /**
     * 批量删除贴子
     *
     * @param ids 需要删除的贴子主键
     * @return 结果
     */
    @Override
    public int deleteTbPostByIds(Long[] ids)
    {
        return tbPostMapper.deleteTbPostByIds(ids);
    }

    /**
     * 删除贴子信息
     *
     * @param id 贴子主键
     * @return 结果
     */
    @Override
    public int deleteTbPostById(Long id)
    {
        return tbPostMapper.deleteTbPostById(id);
    }
}
